package ComparableAndComparator;

import java.util.Comparator;

public class Persona implements Comparable {
	private int id;
	private String nombre;
	/**
     * Compare current person with specified person
     * return zero if person_id for both person is same
     * return negative if current person_id is less than specified one
     * return positive if specified person_id is greater than specified one
     */
    @Override
    public int compareTo(Object o) {
    	Persona p = (Persona) o;
        return this.id - p.id ;
    }
    
    
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getNombre() {
		return nombre;
	}
	public void setNombre(String nombre) {
		this.nombre = nombre;
	}



}

class PersonSortByID implements Comparator{
	
	 public int compare(Object o1, Object o2) {
	        Persona p1 = (Persona) o1;
	        Persona p2 = (Persona) o2;
	        return p1.getId() - p2.getId();
	 }
}
